from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Mask(Item):
    def __init__(self):
        Item.__init__(self, "mask")    # do basic initialization for every item
        self.is_on = False
        
        # build list of actions
        self.add_action(PutOn)
        self.add_action(PutOff)
    
    def get_description(self):
        if self.is_on:
            return "mask (On)"
        else:
            return "mask (off)"


# define actions for this item

class PutOn(Action):
    def __init__(self):
        Action.__init__(self, "put_on")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Put on the mask"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # enabled only if lamp is off.
    def is_enabled(self):
        if self.item.is_on:
            return False
        else:
            return True
    
    # turn lamp on and add cutscene
    def do_action(self,game,room,request):
        self.item.is_on = True
        set_cutscene("You put the mask on and now you are invincible!!  Take that toxic smoke!  Hurry up to the 6th floor to help Professor Wyner get out of here alive.")
        return

class PutOff(Action):
    def __init__(self):
        Action.__init__(self, "put_off")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Take off the mask"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # enabled only if lamp is on.
    def is_enabled(self):
        if self.item.is_on:
            return True
        else:
            return False
    
    # turn lamp on and add cutscene
    def do_action(self,game,room,request):
        self.item.is_on = False
        set_cutscene("You put the mask off and feel that it's hard to breathe here.")
        return